package cm.unit2.theme4;

public class JumpFloorII {

	// 可以跳n級（数学归纳法）
	public int jumpFloorII(int target) {
        if(target<1) {
        	return 0;
        }
        else if(target==1) {
        	 return 1;
        }
        else {
        	return 2*jumpFloorII(target-1);
        }
    }
	
	// 可以跳1或2級
	 public int jumpFloor(int target) {
        if(target<1) {
        	return 0;
        }else if(target==1) {
        	 return 1;
        }else if(target==2) {
        	 return 2;
        }else {
        	return jumpFloor(target-1)+jumpFloor(target-2);
        }
    }
	
	public static void main(String[] args) {
		JumpFloorII jumpFloorII = new JumpFloorII();
		for (int i = 0; i < 10; i++) {
			System.out.println(i+"->"+jumpFloorII.jumpFloor(i));
		}
	}
	
}
